package com.gillion.oms.school.student.mapper.impl.model;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Set;
public class StudentColumnRefUtil{

    private static Map<String,String> columnRefMaps = Maps.newHashMap();
    static{
        columnRefMaps.put("studentId","STUDENT.STUDENT_ID");
        columnRefMaps.put("classid","STUDENT.classId");
        columnRefMaps.put("studentName","STUDENT.STUDENT_NAME");
        columnRefMaps.put("studentNm","STUDENT.STUDENT_NM");
        columnRefMaps.put("age","STUDENT.AGE");
        columnRefMaps.put("recordVersion","STUDENT.record_version");
        columnRefMaps.put("createrId","STUDENT.creater_id");
        columnRefMaps.put("updateId","STUDENT.update_id");
        columnRefMaps.put("createTime","STUDENT.create_time");
    }
    /**
    * 获取字段对应的列名
    **/
    public static String getColumnName(String fieldName){
        return columnRefMaps.get(fieldName);
    }
    /**
    * 将类似studentName desc studentNm asc 转化为 t.student_name desc t.student_nm asc
    **/
    public static String generatorOrderBy(String orderByField){
        Set<String> keys = columnRefMaps.keySet();
        for(String key:keys){
            orderByField = orderByField.replaceAll(key,columnRefMaps.get(key));
        }
        return orderByField;
    }



}